package me.spring.cloud.components.starter.swagger;

import me.spring.cloud.components.starter.swagger.properties.SwaggerProperties;
import me.spring.cloud.components.starter.swagger.swagger.SwaggerConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.documentation.swagger.web.DocExpansion;
import springfox.documentation.swagger.web.ModelRendering;
import springfox.documentation.swagger.web.TagsSorter;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 通用Swagger配置
 *
 * @author luffy
 * @date 2018-9-5
 **/
@Configuration
@EnableSwagger2
@EnableConfigurationProperties(SwaggerProperties.class)
@Import(SwaggerConfiguration.class)
public class SwaggerAutoConfiguration {

  @Bean
  UiConfiguration uiConfig() {
    return UiConfigurationBuilder.builder().docExpansion(DocExpansion.LIST).tagsSorter(TagsSorter.ALPHA)
        .defaultModelRendering(ModelRendering.MODEL).build();
  }
}
